package com.keepsport.keepsportapi.controller;

import com.keepsport.keepsportapi.config.SystemConfig;
import com.keepsport.keepsportapi.entity.CommunityRemark;
import com.keepsport.keepsportapi.service.intf.CommunityRemarkService;
import com.keepsport.keepsportapi.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/***
 *         O
 *      _ooOoo_
 *     o8888888o
 *     88" . "88
 *     (| -_- |)
 *      O\ = /O
 *  ____/`---'\____
 *  ...............
 *  佛祖保佑  永无BUG
 *   Data:2022/7/2
 *   Author:King
 *   Description:
 */
@RestController
@RequestMapping("api/remark")
@Api(tags = "评论")
@CrossOrigin
public class CommunityRemarkController {
    @Resource
    private CommunityRemarkService service;

    @ApiOperation("查询")
    @GetMapping("select.do")
    public R select(){
        return service.selectAll();
    }
    @ApiOperation("添加")
    @PostMapping("add.do")
    public R add(@RequestBody CommunityRemark remark, HttpServletRequest request){
        return service.insert(remark,request.getIntHeader(SystemConfig.TOKEN_HEADER));
    }
    @ApiOperation("通过消息id查询所有它的评论")
    @GetMapping("slectAll.do")
    public R slectAll(int id){
        return service.findAllById(id);
    }

}
